﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AL100.BankApplication.BLL
{
    /// <summary>
    /// Factory class for Accounts.
    /// </summary>
    internal static class AccountFactory
    {
        /// <summary>
        /// Creates the appropriate Account type.
        /// </summary>
        /// <param name="holder">The holder.</param>
        /// <param name="deposit">The deposit.</param>
        /// <returns>The appropriate Account type.</returns>
        internal static AccountBase Create(Customer holder, double deposit)
        {
            AccountBase result = null;

            if (deposit > 0 && deposit <= 1000)
            {
                result = new SimpleAccount(holder, deposit);    
            }
            else if (deposit > 1000 && deposit <= 2000)
            {
                result = new SilverAccount(holder, deposit);
            }
            else if (deposit > 3000)
            {
                result = new GoldAccount(holder, deposit);
            }
            else
            {
                throw new NegativeDepositException("Negative Deposit attempt");
            }


            // On  fait renvoyer le compte créé.
            return result;


        }
    }
}
